package com.yenlien.traceyun.webase.exception;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author wangyang@3sqy.cn
 * @version V1.0
 * @date 2017年11月22日
 * @Description:
 */
public class ErrorPageException extends Exception {


    /**
     *
     */
    private static final long serialVersionUID = 5010675577024932123L;
    private Logger logger = LoggerFactory.getLogger(SecurityException.class);

    public ErrorPageException(String message) {
        super(message);
        logger.error(" error msg:{}", message);
    }

    public ErrorPageException() {
        super();
    }

    public ErrorPageException(Throwable throwable) {
        super(throwable);
        log(null, throwable);
    }

    public ErrorPageException(String msg, Throwable throwable) {
        super(throwable);
        log(msg, throwable);
    }

    private void log(String msg, Throwable throwable) {
        if (throwable != null) {
            StackTraceElement element = throwable.getStackTrace()[0];
            String exceptionInfo = null;
            if (element == null)
                return;
            exceptionInfo = "class=" + element.getClassName() + ",method=" + element.getMethodName() + ",file="
                    + element.getFileName() + ",line=" + element.getLineNumber();
            logger.error("error msg:{},exception msg:{}", msg, exceptionInfo);
        }
        printStackTrace();
    }
}
